/**

 @Name：layim v3.7.7 Pro 商用版
 @Author：贤心
 @Site：http://layim.layui.com
 @License：LGPL

 */

layui.define(['layer', 'laytpl', 'upload'], function(exports){

    var v = '3.7.7';
    var $ = layui.$;
    var layer = layui.layer;
    var laytpl = layui.laytpl;
    var device = layui.device();

    var SHOW = 'layui-show', THIS = 'layim-this', MAX_ITEM = 20;
    var cache = layui.layim.cache();
    //回调
    var call = {};

    //对外API
    var XCCHAT = function(){
        this.v = v;
        $('body').on('click', '*[xcchat-event]', function(e){
            var othis = $(this), methid = othis.attr('xcchat-event');
            xc_events[methid] ? xc_events[methid].call(this, othis, e) : '';
        });
    };


    //事件
    var xc_events = {
        showUserDetail: function (othis) {
            var user_id = othis.attr('xcchat-id');
            var type = othis.attr('xcchat-type');
            var user_name = othis.html();
            if (!cache.base.showUserDetail) {
                return layer.msg('未开启资料展示');
            }
            layer.close(xc_events.showUserDetail.index);
            return xc_events.showUserDetail.index = showUserDetail(user_id,type,user_name);
        }
    };
    
    var showUserDetail = function (user_id,type,user_name) {
        var title = '';
        if(cache.mine.id == user_id){
            title = '我的资料';
        }else{
            title = user_name + '的资料';
        }
        layer.open({
            type: 2
            ,offset: 'auto'
            ,id: 'userInfo'+user_id
            ,title: title
            ,area: ['650px', '750px']
            ,content: cache.base.showUserDetail + '?id=' + user_id + '&type=' + type
            ,btnAlign: 'c' //按钮居中
            ,moveType: 1
            ,shade: 0 //不显示遮罩
            ,yes: function(){

            }
        });
    };



    //暴露接口
    exports('xcchat', new XCCHAT());

}).addcss(
    'modules/layim/layim.css?v=3.7.7'
    ,'skinlayimcss'
);